Repository navigation
wasi-http: validate the Host header used as incoming request authority - #15023
Open
netliomax25-code wants to merge 1 commit into
Open
netliomax25-code wants to merge 1 commit into
netliomax25-code wants to merge 1 commit into
Conversation
netliomax25-code
requested review from
rvolosatovs
and removed request for
a team
October 27, 2026 07:01
rvolosatovs
approved these changes
Oct 27, 2026
rvolosatovs
left a comment
Member
There was a problem hiding this comment.
generally, values passed by the embedder to wasi-http are assumed to be valid (e.g. we don't validate Content-Length of a body originating from the host)
Following this approach, I'd expect wasmtime serve to perform this validation before passing the incoming request to e.g. new_incoming_request.
All that said, it is a fairly small change and a quick check, and performing this validation on construction, at least as a safeguard, seems harmless so LGTM
Contributor
|
Thank you! #14988 is already covered |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When an incoming request's target has no authority (the usual origin-form
GET /path),incoming-request.authorityfalls back to theHostheader. The p2 path innew_incoming_requestcopied that header string verbatim, so a client can hand the guest an "authority" that is not one at all. Withwasmtime serveand a p2 proxy component, theseHostvalues all come through unchanged today:A guest that checks the authority with something like
ends_with(".example.com")and then buildshttp://{authority}/...for a redirect or an absolute link ends up pointing atevil.com. The p3 path inPrepared::newalready parses the header withhttp::uri::Authority, which rejects the first three of these but still accepts userinfo and a non-numeric port.Both incoming paths now use the crate's existing
parse_authority, which already enforces theuri-host [":" port]grammar for outgoing authorities. For p2 an invalidHostgets a 400, as RFC 9112 section 3.2 requires and as p2 already does for a missingHost. p3 keeps its current behavior of leaving the authority unset when the header doesn't parse. Requests whose target carries an authority are unchanged.I added a unit test next to
set_status_code_rangethat checks valid hosts (including[::1]:443) still come through and the values above get a 400. It fails without the fix and passes with it.cargo test -p wasmtime-wasi-http(unit, integration and doc tests),cargo clippy -p wasmtime-wasi-http --all-targetsandcargo fmt --all -- --checkall pass locally.